package com.redteam.xomtro.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.redteam.xomtro.MasterActivity;
import com.redteam.xomtro.R;
import com.redteam.xomtro.entities.Comment;

import java.util.ArrayList;
import java.util.List;

public class ProfileTab_Comment extends PlaceTabFragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View r = inflater.inflate(R.layout.fragment_profile_comment, container, false);
        assert r != null;
        List<Comment> lstComment = new ArrayList<Comment>();
        lstComment.add(new Comment("Quang Vũ", "http://lorempixel.com/96/96/people",
                "cool"));
        lstComment.add(new Comment("Hà Dương", "http://lorempixel.com/96/96/people",
                "hôm qua em tới trường mẹ dắt tay từng bước ớ ơ, hôm nay mẹ lên nương một mình em tới lớp ớ ơ hương rừng thơm đồi vắng nước suối trong thầm thì cọ xèo ô che nắng râm mát đường em đi"));
        lstComment.add(new Comment("Hà Hồ", "http://lorempixel.com/96/96/people",
                "anh Dương hát hay hơn cả em <3"));

        LinearLayout listCommentView = (LinearLayout) r.findViewById(R.id.llListComment);
        for (Comment it : lstComment) {
            View item = View.inflate(activity, R.layout.item_comment, null);
            ((TextView) item.findViewById(R.id.tvCommenterName)).setText(it.getUsername());
            ((TextView) item.findViewById(R.id.tvCommentContent)).setText(it.getConnent());
            ImageView commenterAvatar = (ImageView) item.findViewById(R.id.ivCommenterAvatar);
            imageLoader.displayImage(it.getAvatar(), commenterAvatar, optionsAvatar);
            listCommentView.addView(item);
        }
        return r;
    }

    public ProfileTab_Comment newInstance(MasterActivity mainActivity) {
        super.newInstance(mainActivity);
        return this;
    }
}
